package com.fu.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.models.Contact;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 
 * @author Little Ant
 * @date 2017年10月30日下午1:33:59
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {
	@Bean
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
				.apis(RequestHandlerSelectors.basePackage("com.fu.controller")).paths(PathSelectors.any()).build();
	}

	private ApiInfo apiInfo() {
		Contact contact = new Contact();
		contact.setName("EMO");
		contact.setEmail("xgz.cz@foxmail.com");
		contact.setUrl("xgz.space");
		ApiInfo info = new ApiInfoBuilder().title("RESTful-API文档")
				.description("使用swagger2自动构建,官方文档:https://swagger.io/docs/").version("1.0").build();
		return info;
	}
}
